﻿/* ============================================================================== 
 * 功能描述：MainPanelRewardGoodsItem 
 * 创 建 者：Administrator
 * 创建日期：2016/5/4 20:36:51 
 * ==============================================================================*/

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ZZQFrameWork;

public class MainPanelRewardGoodsItem:MonoBehaviour,IPool
{
    protected Image iconImage;
    protected Text countText;

    public GoodsVO Data { get; private set; }

    void Awake()
    {
        iconImage = transform.GetComponentByPath<Image>("GoodsIcon");
        countText = transform.GetComponentByPath<Text>("Count");
    }

    public void SetData(Enum_TaskRewardType type,int rewardId,int count)
    {
        if (type==Enum_TaskRewardType.Equip)
        {
            SetData(new GoodsVO(EquipConfigProvider.Instance.GetEquipById(rewardId)),count);
        }
        else
        {
            SetData(new GoodsVO(GoodsConfigProvider.Instance.GetGoodsById(rewardId)),count);
        }
    }

    public void SetData(GoodsVO goods, int count)
    {
        Data = goods;
        if (goods.goodsType == Enum_GoodsType.Equip)
        {
            iconImage.sprite = UIAtlasManager.Instance.GetUIAtlasByName("Equip_Atlas").GetSprite(Data.icon);
        }
        else
        {
            iconImage.sprite = UIAtlasManager.Instance.GetUIAtlasByName("Goods_Atlas").GetSprite(Data.icon);
        }
        countText.text = count.ToString();
    }

    public void Spawn()
    {
        
    }

    public void UnSpawn()
    {
    }
}
